package redbencity.com.richtext.richeditor;

import android.graphics.Typeface;
import android.text.style.BackgroundColorSpan;
import android.text.style.BulletSpan;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.ParagraphStyle;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;

public class TextStyleFactory {
    public static final int NORMAL_SPAN = 0;
    public static final int ALIGNMENT_SPAN = 1;
    public static final int FOREGROUND_COLOR_SPAN = 2;
    public static final int RELATIVE_SIZE_SPAN = 3;
    public static final int SCALE_X_SPAN = 4;
    public static final int STRIKETHROUGH_SPAN = 5;
    public static final int UNDERLINE_SPAN = 6;
    public static final int STYLE_SPAN = 7;
    public static final int BULLET_SPAN = 8;
    public static final int QUOTE_SPAN = 9;
    public static final int LEADING_MARGIN_SPAN = 10;
    public static final int URL_SPAN = 11;
    public static final int BACKGROUND_COLOR_SPAN = 12;
    public static final int TYPEFACE_SPAN = 13;
    public static final int SUPERSCRIPT_SPAN = 14;
    public static final int SUBSCRIPT_SPAN = 15;
    public static final int ABSOLUTE_SIZE_SPAN = 16;
    public static final int TEXT_APPEARANCE_SPAN = 17;
    public static final int ANNOTATION = 18;
    public static final int SUGGESTION_SPAN = 19;
    public static final int SPELL_CHECK_SPAN = 20;
    public static final int SUGGESTION_RANGE_SPAN = 21;
    public static final int EASY_EDIT_SPAN = 22;
    public static final int LOCALE_SPAN = 23;
    public static final int TTS_SPAN = 24;
    public static final int BOLD_SPAN = 25;
    public static final int ITALIC_SPAN = 26;

    public static int textColor = 0xff000000;
    public static int textBgColor = 0xffffffff;

    static CharacterStyle createCharacter(int type) {
        switch (type) {
            case BOLD_SPAN:
                return new StyleSpan(Typeface.BOLD);
            case ITALIC_SPAN:
                return new StyleSpan(Typeface.ITALIC);
            case BACKGROUND_COLOR_SPAN:
                return new BackgroundColorSpan(textBgColor);
            case UNDERLINE_SPAN:
                return new UnderlineSpan();
            case FOREGROUND_COLOR_SPAN:
                return new ForegroundColorSpan(textColor);
            default:
                throw new IllegalArgumentException("not span");
        }
    }

    static ForegroundColorSpan createForegroundColorSpan(int color) {
        return new ForegroundColorSpan(color);
    }

    static BackgroundColorSpan createBackgroundColorSpan(int color) {
        return new BackgroundColorSpan(color);
    }


    static ParagraphStyle createParagraph(int type) {
        switch (type) {
            case BULLET_SPAN:
                return new BulletSpan(15, 0xff00ff00);
            default:
                throw new IllegalArgumentException("not span");
        }
    }

}
